﻿
namespace Company.Shell.Dialogs
{
    public class DialogResult<TResult>
    {

        public DialogResult(IDialogViewModel<TResult> VM)
        {
            if (VM == null) throw new ArgumentNullException(nameof(VM));
            Result = VM.Result;
            Success = VM.Success;   
        }

        /// <summary>
        /// 对话框返回的结果
        /// </summary>
        public TResult? Result { get; set; }
        /// <summary>
        /// 用户按下对话的确定状态
        /// </summary>
        public bool Success { get; private set; }

        public void SetSuccess(bool? success)
        {
            if (success != null)
            {
                Success = success.Value;
            }

        }
    }
}
